/**
 * Copyright (c) 2018-2028, LookAhead.
 * <p>
 * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p>
 * http://www.gnu.org/licenses/lgpl.html
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.lookahead.parent.database.base;

import com.baomidou.mybatisplus.extension.service.IService;

import javax.validation.constraints.NotEmpty;
import java.util.Collection;
import java.util.List;

/**
 * 基础业务接口
 *
 * @param <T>
 * @author LookAhead
 */
public interface BaseService<T> extends IService<T> {

    /**
     * 保存
     *
     * @param entity 实体类
     * @return boolean
     */
    @Override
    boolean save(T entity);

    /**
     * 修改
     *
     * @param entity 实体类
     * @return boolean
     */
    @Override
    boolean updateById(T entity);

    /**
     * 逻辑删除
     *
     * @param ids id集合(逗号分隔)
     * @return boolean
     */
    boolean deleteLogic(@NotEmpty List<Long> ids);

    /**
     * 批量保存
     *
     * @param entityList 实体类List
     * @return boolean
     */
    @Override
    boolean saveBatch(Collection<T> entityList);

    /**
     * 批量更新
     *
     * @param entityList 实体类List
     * @return boolean
     */
    @Override
    boolean updateBatchById(Collection<T> entityList);

    /**
     * 更新或新增
     *
     * @param entity 实体类
     * @return boolean
     */
    @Override
    boolean saveOrUpdate(T entity);

    /**
     * 批量更新或新增
     *
     * @param entityList 实体类List
     * @param batchSize  每次数量
     * @return boolean
     */
    @Override
    boolean saveOrUpdateBatch(Collection<T> entityList, int batchSize);

}
